negotiator.issue
Class IssueDiscrete

java.lang.Object
  extended by negotiator.issue.Objective
      extended by negotiator.issue.Issue
          extended by negotiator.issue.IssueDiscrete
All Implemented Interfaces:
java.io.Serializable, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode

public class IssueDiscrete
extends Issue

Specific type of issue in which the value of the issue are a set of objects. An example of a discrete issue is the color of car with the values {Red, Blue, Black}.

Author:
Tim Baarslag & Dmytro Tykhonov
See Also:
Serialized Form

Constructor Summary
IssueDiscrete(java.lang.String name, int issueNumber, java.lang.String[] values)
          Create a new discrete issue given the name of the issue, its unique ID, and an array of possible values.
IssueDiscrete(java.lang.String name, int issueNumber, java.lang.String[] values, Objective objParent)
          Create a new discrete issue given the name of the issue, its unique ID, its parent, and an array of possible values.
IssueDiscrete(java.lang.String name, int issueNumber, java.lang.String[] values, java.lang.String[] descriptions, Objective objParent)
          Create a new discrete issue given the name of the issue, its unique ID, its parent, and an array of possible values and a description for each value.
 
Method Summary
 void addValue(java.lang.String valname)
          Adds a value.
 void addValues(java.lang.String[] valnames)
          Adds values.
 boolean checkInRange(Value value)
          Method to check if the given value is in the range specified by the issue.
 void clear()
          Removes all values from this Issue.
 java.lang.String convertToString()
           
 boolean equals(java.lang.Object o)
           
 java.lang.String getDesc(ValueDiscrete value)
           
 int getNumberOfValues()
           
 java.lang.String getStringValue(int index)
           
 ISSUETYPE getType()
          This method is added for convenience.
 ValueDiscrete getValue(int index)
          Get value by its Sting representation, null otherwise.
 int getValueIndex(java.lang.String value)
           
 int getValueIndex(ValueDiscrete value)
           
 java.util.List<ValueDiscrete> getValues()
          Gives an enumeration over all values in this discrete issue.
 void setDesc(ValueDiscrete val, java.lang.String desc)
          Sets the desc for value val.
 SimpleElement toXML()
          Returns a SimpleElement representation of this issue.
 
Methods inherited from class negotiator.issue.Issue
addChild
 
Methods inherited from class negotiator.issue.Objective
children, equalContents, getAllowsChildren, getChildAt, getChildCount, getChildren, getChildWithID, getDescription, getHighestObjectiveNr, getIndex, getName, getNumber, getObjective, getParent, getPath, getPreorderEnumeration, getPreorderIssueEnumeration, getPreorderObjectiveEnumeration, getSiblings, getUserObject, hashCode, insert, isIssue, isLeaf, isObjective, isParent, remove, remove, removeFromParent, setDescription, setName, setNumber, setParent, setUserObject, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IssueDiscrete

public IssueDiscrete(java.lang.String name,
                     int issueNumber,
                     java.lang.String[] values)
Create a new discrete issue given the name of the issue, its unique ID, and an array of possible values.

Parameters:
name - of the issue.
issueNumber - uniqueID of the isue.
values - which the issue may take.

IssueDiscrete

public IssueDiscrete(java.lang.String name,
                     int issueNumber,
                     java.lang.String[] values,
                     Objective objParent)
Create a new discrete issue given the name of the issue, its unique ID, its parent, and an array of possible values.

Parameters:
name - of the issue.
issueNumber - uniqueID of the isue.
values - which the issue may take.
objParent - parent objective of the issue.

IssueDiscrete

public IssueDiscrete(java.lang.String name,
                     int issueNumber,
                     java.lang.String[] values,
                     java.lang.String[] descriptions,
                     Objective objParent)
Create a new discrete issue given the name of the issue, its unique ID, its parent, and an array of possible values and a description for each value.

Parameters:
name - of the issue.
issueNumber - uniqueID of the isue.
values - which the issue may take.
descriptions - array with a description for each value.
objParent - parent of the issue.
Method Detail

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class Objective
Returns:
true if given object is an Objective and number, name, and children are the same we don't care about the description and user objects.

getNumberOfValues

public int getNumberOfValues()
Returns:
amount of values.

getValue

public ValueDiscrete getValue(int index)
Get value by its Sting representation, null otherwise.

Parameters:
index - of the value to be returned.
Returns:
value with the given index in the array of values for this issue.

getStringValue

public java.lang.String getStringValue(int index)
Parameters:
index - of the value.
Returns:
string of the value, for example "Red".

getValueIndex

public int getValueIndex(java.lang.String value)
Parameters:
value - that is supposed to be one of the alternatives of this issue.
Returns:
index holding that value, or -1 if value is not one of the alternatives.

getValueIndex

public int getValueIndex(ValueDiscrete value)
Parameters:
value - that is supposed to be one of the alternatives of this issue.
Returns:
index holding that value, or -1 if value is not one of the alternatives.

clear

public void clear()
Removes all values from this Issue.


addValue

public void addValue(java.lang.String valname)
Adds a value.

Parameters:
valname - The name of the value to add.

addValues

public void addValues(java.lang.String[] valnames)
Adds values.

Parameters:
valnames - Array with names of values to add.

checkInRange

public boolean checkInRange(Value value)
Description copied from class: Issue
Method to check if the given value is in the range specified by the issue.

Specified by:
checkInRange in class Issue
Parameters:
value - to be checked.
Returns:
true if in range.

getValues

public java.util.List<ValueDiscrete> getValues()
Gives an enumeration over all values in this discrete issue.

Returns:
An enumeration containing valueDiscrete

toXML

public SimpleElement toXML()
Returns a SimpleElement representation of this issue.

Overrides:
toXML in class Issue
Returns:
The SimpleElement with this issues attributes

setDesc

public void setDesc(ValueDiscrete val,
                    java.lang.String desc)
Sets the desc for value val. If the value doesn't exist yet in this Evaluator, add it as well.

Parameters:
val - The value to have it's desc set/modified
desc - The new desc of the value.

getDesc

public java.lang.String getDesc(ValueDiscrete value)
Parameters:
value -
Returns:
description of the given value. A description is an optional explanation of the value.

getType

public ISSUETYPE getType()
Description copied from class: Objective
This method is added for convenience. It is simply an alternative implementation of the getType method from the Issue class. It will always return that the type is Objective. This method must be overridden in Issue to return the type of the Issue.

Specified by:
getType in class Issue
Returns:
ISSUETYPE.OBJECTIVE

convertToString

public java.lang.String convertToString()
Specified by:
convertToString in class Issue
Returns:
corresponding string representation